package cn.gson.springboot.controller.cuscontroller;

import cn.gson.springboot.model.service.cusservice.CuViewService;
import cn.gson.springboot.model.vo.cusvo.CuSelectOrderNum;
import cn.gson.springboot.model.vo.cusvo.CuViewVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@RequestMapping("/vue")
@Controller
public class CuViewController {
    @Autowired
    CuViewService cuViewService;

    //    客户创建时间的月份
    @RequestMapping("/create-month")
    @ResponseBody
    public List<String> createMonth(Integer empId){
        System.out.println("empId:"+empId);
        return cuViewService.createMonth(empId);
    }

    //    各月份的创建客户数量统计
    @RequestMapping("/create-month-count")
    @ResponseBody
    public List<String> createMonthCount(Integer empId){
        return cuViewService.createMonthCount(empId);
    }

    //    查询当前登录员工的客户总数量
    @RequestMapping("/nums")
    @ResponseBody
    public Integer nums(Integer empId,Integer deptId,String str){
        String[] date=new String[2];
        String startTime="";
        String endTime="";
        if(str!=null && str!=""){
            date=str.split(",");
            startTime=date[0];
            endTime=date[1];
        }
        return cuViewService.nums(empId,deptId,startTime,endTime);
    }

    //  查询当前登录员工的客户类型比率
    @RequestMapping("/type")
    @ResponseBody
    public List<CuViewVo> type(Integer empId,Integer deptId,String str){
        String[] date= new String[2];
        String startTime="";
        String endTime="";
        if(str!=null && str!=""){
            date=str.split(",");
            startTime=date[0];
            endTime=date[1];
        }
        return cuViewService.type(empId,deptId,startTime,endTime);
    }

    //    客户分布
    @RequestMapping("/china")
    @ResponseBody
    public List<CuViewVo> china(Integer empId){
        return cuViewService.china(empId);
    }

    //    查询下单数量
    @RequestMapping("/order-num")
    @ResponseBody
    public Map<String, List> selectOrderNum(Integer empId,Integer deptId,String str){
        System.out.println("str:"+str+empId);
        String[] date= new String[2];
        String startTime="";
        String endTime="";
        if(str!=null && str!=""){
            date=str.split(",");
            startTime=date[0];
            endTime=date[1];
        }
        return cuViewService.selectOrderNum(empId,deptId,startTime,endTime);
    }
}
